package 刷题;

import java.util.Scanner;

public class 译密码 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("输入想要加密的字符串");
        String str = scan.nextLine();
        char[] ch = str.toCharArray();
        for(int i =0;i<ch.length;i++){
            if(ch[i]=='z'||ch[i]=='Z'){
                //参与运算的字符对应的ASCII码值
                ch[i]-=25;
            }else if(('A'<=ch[i]&&ch[i]<='Y')||('a'<=ch[i]&&ch[i]<='y')){
                ch[i]++;
            }
        }
        //将字符串数组转换为字符串调用String.valueOf方法
        String str2 = String.valueOf(ch);
        System.out.println("输出加密过的字符串"+str2);
    }
}
